﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <link href="../../../Scripts/easyUI145/themes/icon.css" rel="stylesheet" type="text/css" />
    <link href="../../../Scripts/easyUI145/themes/default/easyui.css" rel="stylesheet" type="text/css" />
    <link href="../../../../DataUser/Style/ccbpm.css" rel="stylesheet" type="text/css" />
    <link href="../../../Scripts/bootstrap/css/bootstrap.css" rel="stylesheet" type="text/css" />
    <link href="../../../Scripts/bootstrap/css/font-awesome.css" rel="stylesheet" />
    <script src="../../../Scripts/easyUI145/jquery.min.js" type="text/javascript"></script>
    <script src="../../../Scripts/easyUI145/jquery.easyui.min.js" type="text/javascript"></script>
    <script src="../../../Scripts/QueryString.js" type="text/javascript"></script>
    <script src="../../../Scripts/config.js" type="text/javascript"></script>
    <script src="../../../Comm/JScript.js" type="text/javascript"></script>
    <script src="../../../Scripts/CommonUnite.js" type="text/javascript"></script>
    <script src="../../../Scripts/EasyUIUtility.js" type="text/javascript"></script>
    <script src="../../../Scripts/QueryString.js" type="text/javascript"></script>
    <script src="../../../Comm/Gener.js" type="text/javascript"></script>
    <script type="text/javascript" src="../../../Scripts/bootstrap/js/jquery.min.js"></script>
    <script type="text/javascript" src="../../../Scripts/bootstrap/js/bootstrap.min.js"></script>
    <!-- 自己的系统风格统一. -->
    <link href="../../../Style/skin/adminfont/iconfont.css" rel="stylesheet" />
    <link href="../../../Style/skin/css/Default.css" rel="stylesheet" />

    <!-- 自己的系统风格统一end -->
    <script src="DDLBar.js" type="text/javascript"></script>
    <script src="../../CCFlowEnum.js" type="text/javascript"></script>
    <style>
        .contentCt{
            text-align:center;
        }
    </style>

    <script type="text/javascript">
        var nodeFrmID = "";
        var keyWord = "";
        $(function () {

            GetData();


        });

        function SearchIt() {
            keyWord = window.prompt('请输入关键字', keyWord);
            if (keyWord == null || keyWord == undefined)
                keyWord = "";
            GetData();
        }

        function GetData() {
            var handler = new HttpHandler("BP.WF.HttpHandler.WF_Admin_AttrNode_FrmSln");
            handler.AddPara("NodeID", GetQueryString("NodeID"));
            handler.AddPara("KeyWord", keyWord);
            var data = handler.DoMethodReturnString("RefOneFrmTreeFrms_Init");

            if (data.indexOf('err@') == 0) {
                alert(data);
                $("#frms").html("");
                return;
            }

            data = JSON.parse(data);
            if (data.length == 0) {
                var html2 = "没有可供选择的表单。";
                $("#frms").html("");
                $("#info").html(html2);
                return;
            }
            var html = "";
            //生成分组的字符串.
            var res = [];
            for (var i = 0; i < data.length; i++) {
                var ens = data[i].SortName
                if (res.indexOf(ens) === -1)
                    res.push(ens);
            }
            var num = 0;
            var nameNo = '';
            for (var i = 0; i < res.length; i++) {
                var SortName = res[i]
                html += "<tr style='35px'>";
                html += "<th colspan=8 class='table-title' onclick=\"GroupBarClick('" + SortName + "')\"> <i class='fa fa-minus-square' alert='Min'  id='Img" + SortName + "'></i><span>" + ' &nbsp; ' + SortName + "</span></th> ";
                html += "</tr>";
      
                for (var j = 0; j < data.length; j++) {
                    var en = data[j];
                    if (SortName === en.SortName) {
                        console.log(en);
                        ++num;
                        html += "<tr id='Img" + en.SortName +num+"'>";
                        html += "<td>" + j + "</td>";
                        html += "<td>" + en.No + "</td>";
                        html += "<td>" + en.Name + "</td>";
                        html += "<td>" + en.PTable + "</td>";
                        if (en.OrgName == null || en.OrgName == undefined || en.OrgName == "")
                            html += "<td class='contentCt'>—</td>";
                        else
                            html += "<td class='contentCt'>" + en.OrgName + "</td>";
                        html += "<td class='contentCt'><a href=\"javascript:Save('" + en.No + "')\">绑定</a></td>";
                        html += "</tr>";
                    }
                }
            }
            $("#frms").html(html);
        }
   


            function Save(selectFrm) {

            if (window.confirm('您确定要绑定:' + selectFrm + "吗？") == false)
                return;

            //选择的表单.
            if (selectFrm == undefined || selectFrm == null) {
                alert('请选择一个表单');
                return;
            }

            var FK_Node = GetQueryString("NodeID");
            var node = new Entity("BP.WF.Node", FK_Node);
            node.NodeID = FK_Node;
            var i = node.RetrieveFromDBSources();

            //更新节点表单类型.
            node.FormType = FormSlnType.RefOneFrmTree;
            node.NodeFrmID = selectFrm; //选择的表单
            node.RefOneFrmTreeType = $("#DDL_FrmTree").val();

            var update = node.Update(); //执行更新.

            //节点表单属性
            var frmNode = new Entity("BP.WF.Template.FrmNode");
            frmNode.Delete("FK_Node", node.NodeID); //删除已经存在的表单.

            frmNode.MyPK = selectFrm + "_" + node.NodeID + "_" + node.FK_Flow;
            var i = frmNode.RetrieveFromDBSources();
            frmNode.FK_Node = node.NodeID;
            frmNode.FK_Flow = node.FK_Flow;
            frmNode.FK_Frm = selectFrm;
            frmNode.Save(); //执行保存.

            var html = "<a href=\"javascript:EditFrmNode('" + frmNode.MyPK + "')\" >编辑关联的表单属性</a> - <a href=\"javascript:SetAllNodeFrmUseThisSln()\">设置该流程所有的节点都采用此表单方案</a>";
            $("#Div_RefOneFrmTree").html(html);
            alert("独立表单库表单 - 保存成功.");
            parent.location.reload();
            parent.doCloseDialog.call();

            // parent.$("#MyFrm").html(frmNode.FK_Frm + ":" +selectName );
            // $(".panel-tool-close").click();

            return;
        }
        function GroupBarClick(groupName) {

            var alt = document.getElementById('Img' + groupName).alert;
            var sta = 'block';
            if (alt == 'Max') {
                sta = 'block';
                alt = 'Min';
                classname = 'fa fa-minus-square';
            } else {
                sta = 'none';
                alt = 'Max';
                classname = 'fa  fa-plus-square';
            }

            document.getElementById('Img' + groupName).className = classname;
            document.getElementById('Img' + groupName).alert = alt;

            var i = 0;
            for (i = 0; i <= 600; i++) {

                var row = document.getElementById('Img'+groupName + i);
               
                if (row == null || row == undefined )
                    continue;
                console.log(row);

                if (sta == 'block') {
                    row.style.display = '';
                } else {
                    row.style.display = sta;
                }
            }
        }

    </script>
</head>
<body>
    <div id="table">
        <div>
            <table style="width:100%">
                <thead>
                    <tr>
                        <th style="width:10%">序号</th>
                        <th style="width:20%">表单ID</th>
                        <th style="width:20%">名称<div style='float:right'><img src='../../../Img/Search.png' style='width:24px;' onclick='SearchIt();' /></div></th>
                        <th style="width:20%">存储表</th>
                        <th>创建组织</th>
                        <th style="width:10%">操作</th>
                    </tr>
                </thead>
                <tbody id="frms">

                </tbody>
            </table>
        </div>
        <div id="info"></div>
    </div>
</body>
</html>
